package com.huaxindata.im.http;

import com.huaxindata.common.http.ResponseBean;
import com.huaxindata.im.constants.http.HttpConstants;
import com.huaxindata.im.login.HostUser;
import com.huaxindata.im.main.chat.bean.FileMsgResponseBean;
import com.huaxindata.im.main.contactview.friend.model.UserModel;
import com.huaxindata.im.model.HxSearchByLonLatBean;
import com.huaxindata.im.model.contact.ContactGroup;
import com.huaxindata.im.model.contact.UserMessage;

import okhttp3.MultipartBody;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Query;

/**
 * Created by Administrator on 2017/8/16.
 * 网络请求的接口
 */

public interface HttpApi {

    @GET(HttpConstants.LOGIN_URL)
    Call<HostUser> login(@Query("username") String username, @Query("password") String password);
    //获取好友列表
    @GET(HttpConstants.USER_LIST_URL)
    Call<String> getUserList();

    //根据手机号搜索用户
    @GET(HttpConstants.USER_INFO_URL)
    Call<UserModel> findFriendByPhone(@Query("phoneNum") String phoneNum);

    //创建群，不带群图片
    @POST(HttpConstants.CREATE_GROUP_URL)
    @Multipart
    Call<ContactGroup> createGroup(@Part("name") String name, @Part("members") String members);
    //创建群，带图片
    @POST(HttpConstants.CREATE_GROUP_PICTURE_URL)
    @Multipart
    Call<ContactGroup> createGroupWithPic(@Part MultipartBody.Part file, @Part("name") String name, @Part("members") String members);
    //删除好友
    @GET(HttpConstants.DELETE_FRIEND_URL)
    Call<String> delFriend(@Query("userId") String userId, @Query("friendId") String friendId);

    /**
     * 上传文件
     * @param file
     * @return
     */
    @Multipart
    @POST(HttpConstants.CHAT_UPLOAD_FILE)
    Call<FileMsgResponseBean> uploadMsgFile2(@Part MultipartBody.Part file);

    //添加好友
    @GET(HttpConstants.ADD_FRIEND_URL)
    Call<ResponseBean> addFriend(@Query("userId") String userId, @Query("friendId") String friendId);

    //解散群
    @POST(HttpConstants.DESTROY_GROUP)
    Call<ResponseBean> deleteGroup(@Query("clientId") String groupId);

    //根据自己的地理位置获取附近的用户
    @GET(HttpConstants.ADJACENT_USER)
    Call<HxSearchByLonLatBean> findFriendByNear(@Query("lon") double lon, @Query("lat") double lat);

    @GET(HttpConstants.USER_MESSAGE_URL)
    Call<UserMessage> getUserById(@Query("userId") String userId);
}
